01.c - Data-Flow-&-Correlation
Relevant source files
Purpose and ScopeLink copied!
This document explains the critical data flow that links payment to repository access in godeep.wiki. The system faces a fundamental challenge: a customer pays via Stripe, then separately connects their GitHub account, and the owner must correlate these two independent events without a database. This page details how the session_id serves as the correlation key, how cookies temporarily bridge the payment and GitHub connection phases, and why manual log inspection remains necessary for operation.
For the complete payment processing flow, see Payment Processing. For GitHub authentication details, see Authentication & GitHub Integration. For the automation pipeline that consumes correlated data, see Automation System.
The Correlation ChallengeLink copied!
The system processes two asynchronous, independent events:
| Event | Source | Identifying Data | Timestamp |
|---|---|---|---|
| Payment completion | Stripe webhook | session_id, customer_email | Event time |
| GitHub connection | OAuth callback | installation_id, github_username | Callback time |
Without a database, these events cannot be automatically linked. The system must preserve correlation data through the user's browser session and reconstruct the relationship via log analysis.
Sources: CLAUDE.md L44-L50
Session ID as Correlation KeyLink copied!
The Stripe session_id serves as the golden thread linking payment to repository access. This identifier is:
- Generated by Stripe during checkout session creation
- Immutable throughout the user journey
- Logged at every critical correlation point
- Used by the owner to match payment records with repository installations
Session ID Flow Through the SystemLink copied!
Sources: app/api/auth/github/callback/route.ts L39-L50
Cookie-Based State ManagementLink copied!
The system uses HTTP cookies to preserve the session_id during the GitHub OAuth redirect flow, which would otherwise lose query parameters.
State Cookie StructureLink copied!
The github_oauth_state cookie contains a Base64-encoded JSON object:
| Field | Purpose | Example |
|---|---|---|
nonce | CSRF protection | UUID v4 random string |
sessionId | Payment correlation | cs_test_a1b2c3d4e5f6... |
Cookie Configuration:
- Path:
/(application-wide) - MaxAge:
3600seconds (1 hour) - HttpOnly:
true(prevents XSS access) - Secure:
truein production (HTTPS only)
State Encoding and DecodingLink copied!
State Verification: app/api/auth/github/callback/route.ts L26-L37
implements CSRF protection by verifying the state parameter from GitHub matches the cookie value before proceeding.
State Decoding: app/api/auth/github/callback/route.ts L39-L50
extracts the session_id from the Base64-encoded state:
const stateData = JSON.parse(Buffer.from(state, 'base64').toString('utf-8'))stripeSessionId = stateData.sessionId
Sources: app/api/auth/github/callback/route.ts L23-L50
Logging and Correlation PointsLink copied!
The system creates correlation data at three critical points, all logged to Vercel's stdout (accessible via Vercel dashboard or CLI):
Correlation Point 1: Payment WebhookLink copied!
app/api/webhooks/stripe/route.ts L48-L59
logs payment completion:
=======================================================================
💰 NEW PAYMENT RECEIVED
=======================================================================
Session ID: cs_test_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
Amount: $10.00
Customer Email: user@example.com
Payment Status: paid
Timestamp: 2024-01-15T10:30:00.000Z
=======================================================================
Correlation Point 2: OAuth CallbackLink copied!
app/api/auth/github/callback/route.ts L99-L111
logs GitHub connection:
================================================================================
🎉 NEW GITHUB APP INSTALLATION
================================================================================
Stripe Session ID: cs_test_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
Installation ID: 12345678
GitHub Username: johndoe
GitHub Email: johndoe@example.com
GitHub User ID: 987654
User Name: John Doe
Setup Action: install
Timestamp: 2024-01-15T10:32:00.000Z
================================================================================
Correlation Point 3: ntfy NotificationsLink copied!
Both webhook and callback send notifications to ntfy.sh with the "Match ID" (last 12 characters of session_id) for easier visual correlation:
Payment Notification: app/api/webhooks/stripe/route.ts L61-L79
Step 1: Payment Received - GoDeep.wiki
💰 Amount: $10.00
📧 Customer: user@example.com
🔑 Match ID: m3n4o5p6
⏰ Time: 1/15/2024, 10:30:00 AM
GitHub Connection Notification: app/api/auth/github/callback/route.ts L113-L137
Step 2: GitHub Connected - GoDeep.wiki
🔑 Installation ID: 12345678
📧 Customer: johndoe@example.com
🔑 Match ID: m3n4o5p6
⏰ Time: 1/15/2024, 10:32:00 AM
Sources: app/api/webhooks/stripe/route.ts L48-L81
app/api/auth/github/callback/route.ts L99-L137
Complete Data Flow DiagramLink copied!
Sources: app/api/webhooks/stripe/route.ts L22-L92
app/api/auth/github/callback/route.ts L1-L149
Manual Correlation WorkflowLink copied!
The owner performs manual correlation through the following steps:
Step 1: Identify Payment in Stripe DashboardLink copied!
- Access Stripe Dashboard → Payments
- Find the $10.00 payment for "DeepWiki Analysis"
- Copy the Session ID (format:
cs_test_...orcs_live_...) - Note the Customer Email
Step 2: Search Vercel LogsLink copied!
- Access Vercel project → Logs
- Search for:
session_id: cs_test_...(the full session ID) - Locate the log entry containing both: *
Stripe Session ID: cs_test_...*Installation ID: 12345678
Step 3: Extract Installation IDLink copied!
From the log entry matching the session ID, extract:
installation_id(numeric identifier)GitHub Username(for verification)GitHub Email(cross-check with Stripe email)
Step 4: Verify Match via ntfy (Optional)Link copied!
If the owner subscribes to ntfy notifications, they can visually match:
- Payment notification Match ID: Last 12 characters of
session_id - GitHub notification Match ID: Same last 12 characters
- Both notifications should show matching customer email/username
Correlation Data TableLink copied!
The logs provide all necessary correlation data:
| Data Point | Source | Used For |
|---|---|---|
session_id | Stripe + OAuth callback | Primary correlation key |
customer_email | Stripe webhook | Customer identification |
installation_id | OAuth callback | Repository access |
github_username | OAuth callback | Verification |
github_email | OAuth callback | Cross-verification |
timestamp | Both logs | Temporal validation |
Sources: CLAUDE.md L35-L43
app/api/auth/github/callback/route.ts L99-L111
The Match ID OptimizationLink copied!
To simplify visual correlation, the system includes a "Match ID" in ntfy notifications—the last 12 characters of the session_id.
Match ID GenerationLink copied!
Payment notification: app/api/webhooks/stripe/route.ts L67
const sessionShort = session.id.slice(-12)
GitHub notification: app/api/auth/github/callback/route.ts L118
const sessionShort = stripeSessionId ? stripeSessionId.slice(-12) : 'Not linked'
Match ID UsageLink copied!
The Match ID enables quick visual correlation when monitoring ntfy notifications:
| Notification | Match ID | Purpose |
|---|---|---|
| Step 1: Payment | m3n4o5p6 | Indicates payment received |
| Step 2: GitHub | m3n4o5p6 | Confirms same customer |
When both notifications show the same Match ID, the owner knows:
- The customer completed both steps
- The correlation is automatic (no log search needed)
- The
installation_idin Step 2 corresponds to the payment in Step 1
Limitation: The Match ID is only useful when monitoring ntfy in real-time. For historical correlation, full log search is still required.
Sources: app/api/webhooks/stripe/route.ts L61-L79
app/api/auth/github/callback/route.ts L113-L137
Correlation Failure ScenariosLink copied!
The system can experience correlation failures in several cases:
Scenario 1: Customer Abandons After PaymentLink copied!
Symptoms:
- Payment log exists with
session_id - No corresponding GitHub installation log
- Customer never clicks "Connect GitHub" button
Detection:
- Stripe payment exists but no matching
installation_idin logs - Time gap > 24 hours between payment and expected GitHub connection
Resolution:
- Contact customer via email from Stripe
- Request GitHub connection completion
- May require refund if customer cannot provide repository access
Scenario 2: State Cookie ExpirationLink copied!
Symptoms:
- Payment log exists
- GitHub installation log exists but shows
Stripe Session ID: NOT PROVIDED - User took > 1 hour between payment and GitHub connection
Detection: app/api/auth/github/callback/route.ts L103
logs NOT PROVIDED when state decoding fails
Resolution:
- Manual correlation via customer email and timestamp
- Match Stripe email with GitHub email/username
- Match timestamps (within reasonable window)
Scenario 3: Multiple Installations by Same UserLink copied!
Symptoms:
- Same
github_usernameappears multiple times - Multiple
installation_idvalues for same user - Unclear which installation corresponds to which payment
Detection:
- Log search returns multiple entries for same username
- Timestamps span multiple days
Resolution:
- Use timestamp proximity (payment time vs. installation time)
- Cross-reference customer email from Stripe with GitHub email
- Contact customer if ambiguous
Sources: app/api/auth/github/callback/route.ts L39-L50
app/api/auth/github/callback/route.ts L103
No Database Design DecisionLink copied!
The system deliberately avoids database usage for several architectural reasons:
Rationale for Log-Based CorrelationLink copied!
| Aspect | Database Approach | Log-Based Approach (Current) |
|---|---|---|
| Infrastructure | Requires DB service (Postgres, Redis) | Uses Vercel's built-in logging |
| Cost | Monthly DB hosting fees | Free (included in Vercel) |
| Complexity | Schema migrations, connection pooling | Zero additional configuration |
| Data retention | Must implement backups | Vercel handles log retention |
| GDPR compliance | Must implement data deletion | Logs naturally expire |
| Failure modes | DB connection failures | Logs always available |
| Volume scaling | Requires sharding at scale | Not designed for scale |
Operational Trade-offsLink copied!
Advantages of no database:
- Zero maintenance overhead
- Simplified deployment (single Vercel project)
- No connection management or pooling
- No database credentials to secure
- Automatic log rotation and retention
Disadvantages of no database:
- Manual correlation required (not automatable)
- Historical queries require log search
- No queryable payment history
- Correlation fails if logs are lost
- Does not scale beyond ~10-20 customers/day
This design reflects the system's philosophy: prioritize simplicity and manual operation over automation and scale.
Sources: CLAUDE.md L1-L11
High-level diagrams (Analysis sections)
Summary: Correlation Key PointsLink copied!
The correlation system operates through these principles:
session_idis the primary correlation key linking payment to repository access- Cookies bridge the OAuth flow preserving
session_idduring GitHub redirects - Logs are the permanent record containing all correlation data
- Manual inspection is required for matching payments to installations
- Match ID provides convenience for real-time ntfy monitoring
- No database simplifies operation at the cost of automation
- System assumes low volume (~10-20 customers/day maximum)
The correlation mechanism is the critical pathway that enables the owner to access customer repositories after payment completion. Understanding this flow is essential for operating and troubleshooting the system.
Sources: CLAUDE.md L32-L50
app/api/auth/github/callback/route.ts L1-L149
app/api/webhooks/stripe/route.ts L1-L92
Refresh this wiki
Last indexed: 23 November 2025 (922b35)
On this page
- Data Flow & Correlation
- Purpose and Scope
- The Correlation Challenge
- Session ID as Correlation Key
- Session ID Flow Through the System
- Cookie-Based State Management
- State Cookie Structure
- State Encoding and Decoding
- Logging and Correlation Points
- Correlation Point 1: Payment Webhook
- Correlation Point 2: OAuth Callback
- Correlation Point 3: ntfy Notifications
- Complete Data Flow Diagram
- Manual Correlation Workflow
- Step 1: Identify Payment in Stripe Dashboard
- Step 2: Search Vercel Logs
- Step 3: Extract Installation ID
- Step 4: Verify Match via ntfy (Optional)
- Correlation Data Table
- The Match ID Optimization
- Match ID Generation
- Match ID Usage
- Correlation Failure Scenarios
- Scenario 1: Customer Abandons After Payment
- Scenario 2: State Cookie Expiration
- Scenario 3: Multiple Installations by Same User
- No Database Design Decision
- Rationale for Log-Based Correlation
- Operational Trade-offs
- Summary: Correlation Key Points
Ask Devin about godeep.wiki-jb